1 using UnityEngine;
2 using
System.Collections;
3
4 public
class BoosterSpringsListener : InputAdapter {
5
6     
public GameObject chooseObject;
7     
public UpgradeLayer upgradeLayer;
8     
public int itemIndex;
9
10     
public override void OnTouchDown()
11     {
12         
if (InputController.Name != InputNames.SHOP) return;
13         
base.OnTouchDown();
14         gameObject.GetComponent<SpriteRenderer>().color =
new Color(0.5f, 0.5f, 0.5f, 1);
15         SoundManager.playButtonSound();
16     }
17
18     
public override void OnCheckUp()
19     {
20         
if (InputController.Name != InputNames.SHOP) return;
21         
base.OnCheckUp();
22         gameObject.GetComponent<SpriteRenderer>().color =
new Color(1, 1, 1, 1);
23         
24     }
25
26     
public override void OnTouchUp()
27     {
28         
if (InputController.Name != InputNames.SHOP) return;
29         chooseObject.transform.localPosition =
new Vector3(gameObject.transform.localPosition.x, gameObject.transform.localPosition.y + 0.01f, chooseObject.transform.localPosition.z);
30         upgradeLayer.UpdateUI(itemIndex);
31     }
32
33     
public void Start () {
34         
if (chooseObject.GetComponent<Actor>() == null)
35             chooseObject.AddComponent<Actor>().addAction(
new ActionRepeat(ActionRepeat.FOREVER, new ActionSequence(
36                 
new ActionScaleTo(0.95f, 0.95f, 0.2f, Interpolation.swingOut),
37                 
new ActionScaleTo(1, 1, 0.2f, Interpolation.swingOut)
38                 )));
39     }
40 }



Trò chơi đua xe động vật trong UNITY Engine 114.783 lượt xem

Gõ tìm kiếm nhanh...